#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <time.h>
#include <pthread.h>
#include <math.h>
#include <limits.h>
#include <unistd.h>


#define CID 1 //connection id
#define TSLENGTH 13
#define SEQLENGTH 8
#define IDLENGTH 1
#define FSIZE 1024
#define BSIZEINF 64
#define PORT 7654
#define DESTINATION1 1
#define DESTINATION2 2
#define RECPORT 7654
#define SENDPORT1 7655
#define SENDPORT2 7656
#define ROUTERSENDRATE 10 //in mili sec
#define TOKENRATE 100 //in mili sec
#define TOKEND 200
#define TOKENMAX 60
#define TOKENREQUIRED 15
#define SIZELENGTH 2
#define DFLUSH 100

typedef struct receiverstruct {
	int socket1, socket2;
	struct sockaddr_in* saddress1;
	struct sockaddr_in* saddress2;
	pthread_mutex_t* mp;
	char** mainbuffer;
} RECEIVERSTRUCT;

void *receiver (void *inputstruct);
void *sender (void *inputstructure);
void *tockenCounter (void *input);
int msleep(unsigned long milisec);
long timestamp();
